import type { NamePath } from 'antd/es/form/interface';
import { get } from '../object';

// 获取shouldUpdate依赖属性的函数
export function shouldUpdateDependencies(namePaths: NamePath[]) {
  return (previous: any, current: any) => {
    const needUpdate = namePaths.some((namePath) => {
      const namePathArr = Array.isArray(namePath) ? namePath : [namePath];
      const isSame = get(previous, namePathArr) === get(current, namePathArr);
      return !isSame;
    });
    return needUpdate;
  };
}
